package com.gupao.javavip.netty.push.protocol;

import com.gupao.javavip.netty.push.client.connection.RetryConnector;
import io.netty.channel.socket.SocketChannel;

public abstract class AbstractPushClientChannelInitializer extends AbstractPushChannelInitializer {
    public AbstractPushClientChannelInitializer() {
        super(false, false, null);
    }

    public AbstractPushClientChannelInitializer(boolean retry, RetryConnector connector) {
        super(false, retry, connector);
    }

    /**
     * Channel初始化处理
     *
     * @param ch
     */
    @Override
    protected void doInitChannel(SocketChannel ch) {
        //Inbound
        ch.pipeline().addLast("response-decoder", new ResponseDecoder());

        //Outbound
        ch.pipeline().addLast("request-encoder", new RequestEncoder());

        doInitPushClientChannel(ch);
    }

    /**
     * 推送客户端Channel初始化处理
     *
     * @param ch
     */
    protected abstract void doInitPushClientChannel(SocketChannel ch);
}
